package simulation.CreatorPackage;

import java.util.Scanner;

import simulation.Factory;
import simulation.FixedMass;
import simulation.Mass;
import simulation.Model;

public class massCreator extends Creator{
	private final Factory myFactory;

	public massCreator(Factory factory) {
		myFactory=factory;
	}

	@Override
	public void createObjectInModel(Scanner line,Model model) {
		  int id = line.nextInt();
	        double x = line.nextDouble();
	        double y = line.nextDouble();
	        double mass = line.nextDouble();
	        Mass result = new Mass(x, y, mass);
	        if (mass<0){
	        	result=new FixedMass(x,y,mass);      	
	        }
	        myFactory.putMassIntoMyMasses(id, result);
	        model.add(result);
	}

}
